
import '../request/api_client.dart';
import '../request/response_data.dart';

class LoginAPI {

  //邮箱登录
  static Future<ResponseData> login(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/SPT/SptUser/sptUser/gmailLogin",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //邮箱验证码登录
  static Future<ResponseData> gmailCodeLogin(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/SPT/sys/app/user/gmailCodeLogin",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //邮箱验证码登录
  static Future<ResponseData> sendEmailLogin(String email) async {
    ResponseData responseData = await ApiClient.post("/SPT/sys/app/user/sendEmailLogin",data: {
      'email':email
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }


  //发送验证码注册
  static Future<ResponseData> sendCode(String email) async {
    ResponseData responseData = await ApiClient.post("/SPT/SptUser/sptUser/sendEmail",data: {
      'email':email
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //发送验证码忘记密码
  static Future<ResponseData> sendPasswordEmail(String email) async {
    ResponseData responseData = await ApiClient.post("/SPT/SptUser/sptUser/sendPasswordEmail",data: {
      'email':email
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //邮箱注册
  static Future<ResponseData> register(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/SPT/SptUser/sptUser/gmailSign",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //邮箱注册
  static Future<ResponseData> forgetPassword(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/SPT/SptUser/sptUser/forgetPassword",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //用户编辑-编辑
  static Future<ResponseData> userEdit(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/SPT/sys/app/user/edit",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //获取code注册存在登录
  static Future<ResponseData> getCodeSignOrLogin(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.post("/SPT/sys/app/user/thirdPartyLogin",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  //判断用户是否存在
  static Future<ResponseData> getUserRegister(Map<String,dynamic> data) async {
    ResponseData responseData = await ApiClient.get("/SPT/sys/app/user/getUserRegister",queryParameters: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

}